%include 'boot.inc'

[bits 32]
extern intr_exit
extern sys_call_table
global syscall_entry
section .text
syscall_entry:
	;error code
	push 0
	push ds
	push es
	push gs
	push fs
	pushad
	mov ax,K_DATA_SEL
	mov ds,ax
	mov es,ax
	push 0x80
	;eax is the sys call number
	mov eax,[esp+0x20]
	;param 3
	push edx
	;param 2
	push ecx
	;param 1
	push ebx
	call [sys_call_table+eax*4]
	add esp,12
	;mov sys call return to user mode eax
	mov [esp+32],eax
	jmp intr_exit
